Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect event name logging with :with option in Wisper event broadcasting #215

Open
qoosuperman opened this issue Jun 26, 2024 · 1 comment · May be fixed by #217
Open

Incorrect event name logging with :with option in Wisper event broadcasting #215

qoosuperman opened this issue Jun 26, 2024 · 1 comment · May be fixed by #217

Comments

@qoosuperman
Copy link

According to the wiki, logging can be enabled with the following initializer settings:

Initializer for logger setup:

# config/initializers/wisper.rb
Wisper.configure do |config|
  config.broadcaster :default, Wisper::Broadcasters::LoggerBroadcaster.new(
    Rails.logger,
    Wisper::Broadcasters::SendBroadcaster.new
  )
end

Code Example:

here's my listener configuration:

# config/initializers/listeners.rb
Rails.application.config.to_prepare do
  Wisper.clear if Rails.env.development? || Rails.env.test?

  Wisper.subscribe(UserCreatedEventHandler, on: :user_created, with: :call)
end

The event handler and the model publishing the event:

# app/event_handlers/user_created_event_handler.rb
class UserCreatedEventHandler
  def self.call(user)
    p('created!!!')
  end
end

# app/models/user.rb
class User < ApplicationRecord
  include Wisper::Publisher

   def do_broadcast
    broadcast(:user_created, self)
  end
end

Triggering the event:

user = User.first
user.do_broadcast
# Observed log message:
# [WISPER] User#1 published call to UserCreatedEventHandler#104080 with User#1

Expected Behavior:
The log message should reflect the actual event name user_created in the output:

# [WISPER] User#1 published user_created to UserCreatedEventHandler#104080 with User#1

Actual Behavior:
The log message incorrectly displays call instead of the event name user_created

I am willing to explore a solution and contribute a fix via a PR.
Please let me know if any other details are required for investigating this issue.

@krisleech
Copy link
Owner

Would happily except a PR to fix 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants